package com.ludomancy.gamelib;

import java.util.Random;

public class Randomizer
{
    private static Random randomGen = new Random();
    
    public static int getRandom(int start, int end)
    {
        if( start == end )
            return start;
        int number = randomGen.nextInt();
        if( number < 0 ) number *= -1;
        return start + (number % (end-start+1));
    }
    
    // returns the value plus or minus <variation>% of the value
    public static int getVariation(int value, int variation)
    {
       int actualVariation = (variation * value) / 100;
       return value + getRandom(-actualVariation,actualVariation);
    }    
}
